//
//  Card.h
//  Guazi
//
//  Created by koolearn on 11-6-1.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "User.h"


@interface Card : NSObject {
    
    long long cardId;
    NSString* name;
    NSString* company;
    NSString* address;
    NSString* postcode;
    NSString* position;
    NSString* mobile;
    NSString* tel;
    NSString* fax;
    NSString* email;
    
    long long userId;
    User* user;
}

@property (nonatomic, assign) long long cardId;
@property (nonatomic, retain) NSString* name;
@property (nonatomic, retain) NSString* company;
@property (nonatomic, retain) NSString* address;
@property (nonatomic, retain) NSString* postcode;
@property (nonatomic, retain) NSString* position;
@property (nonatomic, retain) NSString* mobile;
@property (nonatomic, retain) NSString* tel;
@property (nonatomic, retain) NSString* fax;
@property (nonatomic, retain) NSString* email;
@property (nonatomic, assign) long long userId;
@property (nonatomic, retain) User* user;

- (id) initWithJsonDictionary:(NSDictionary*)dic;
- (id) initWithStatement:(Statement*)stmt;
+ (Card*)cardWithJsonDictionary:(NSDictionary*)dic;
+ (Card*)cardWithStatement:(Statement*)stmt;
+ (Card*)cardWithCard:(Card*)card;
+ (Card*) cardWithId:(long long)cardId;
- (NSString*) toString;

- (void)setValuesFromCard:(Card*)card;

- (void) updateDB;
- (void) deleteDB;
+ (Card*) loadDB:(long long)cardId;
+ (NSArray*) cardsForUser:(long long)auserId;
+ (void) deleteAllCards:(long long)userId;
+ (void) setCardsForUser:(long long)userId cards:(NSArray*)cards;

@end
